/**
 * @note 时间格式yyyy-mm-dd hh:mm:ss
 * @author 吴义迪
 * @create_time 2017-02-27
 */
function timeFormat1(date){
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	if(month < 10){
		month = "0" + month;
	}
	if(day < 10){
		day = "0" + day;
	}
	if(hour < 10){
		hour = "0" + hour;
	}
	if(minute < 10){
		minute = "0" + minute;
	}
	if(second < 10){
		second = "0" + second;
	}
	return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
}

/**
 * @note 时间格式yyyymmddhhmmss
 * @author 吴义迪
 * @create_time 2017-02-27
 */
function timeFormat2(date){
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	if(month < 10){
		month = "0" + month;
	}
	if(day < 10){
		day = "0" + day;
	}
	if(hour < 10){
		hour = "0" + hour;
	}
	if(minute < 10){
		minute = "0" + minute;
	}
	if(second < 10){
		second = "0" + second;
	}
	return "" + year + month + day + hour + minute + second;
}

/**
 * @note 时间格式yyyymmdd000000
 * @author 吴义迪
 * @create_time 2017-11-02
 */
function timeFormat3(date){
	var year = date.getFullYear();
	var month = date.getMonth() + 1;
	var day = date.getDate();
	if(month < 10){
		month = "0" + month;
	}
	if(day < 10){
		day = "0" + day;
	}
	return "" + year + month + day + "000000";
}

/**
 * @note 获取一个月中的日数
 * @param Year 年份
 * @param Month 月份
 * @returns {Number} 所在月份的日数
 * @author 吴义迪
 * @create_time 2017-08-08
 */
function dayNumOfMonthbyYM(Year,Month){
     Month--;
     var d = new Date(Year,Month,1);
     d.setDate(d.getDate()+32-d.getDate());
     return (32-d.getDate());
 }

/**
 * @note 获取一个月中的日数
 * @param d 日期
 * @returns {Number} 所在月份的日数
 * @author 吴义迪
 * @create_time 2017-08-08
 */
 function dayNumOfMonth(d){
     d.setDate(d.getDate()+32-d.getDate());
     return (32-d.getDate());
 }

/**
 * @note 将要素定位到地图中央
 * @author 吴义迪
 * @create_time 2017-02-28
 */
function positionMapCenter(element){
	var elementHeight = element.outerHeight();
	var elementWidth = element.outerWidth();
	var top = $(window).height()/2 - elementHeight/2 + "px";
	var right = $(window).width()/2 - elementWidth/2 + "px";
	element.css({"top":top, "right":right});
}

/**
 * @note 停止地图拖拽
 * @author 吴义迪
 * @create_time 2017-07-17
 */
function stopDragMap() {
    for (var i = 0; i < Global.common.map.events.listeners.mousemove.length; i++) {
        var handler = Global.common.map.events.listeners.mousemove[i];
        if (handler.obj.CLASS_NAME == "SuperMap.Handler.Drag") {
            handler.obj.active = false;
        }
    }
}

/**
 * @note 启动地图拖拽
 * @author 吴义迪
 * @create_time 2017-07-17
 */
function startDragMap() {
    for (var i = 0; i < Global.common.map.events.listeners.mousemove.length; i++) {
        var handler = Global.common.map.events.listeners.mousemove[i];
        if (handler.obj.CLASS_NAME == "SuperMap.Handler.Drag") {
            handler.obj.active = true;
        }
    }
}

/**
 * @note 截取字符串中最后一位指定字符
 * @author 吴义迪
 * @create_time 2017-02-28
 */
function rTrimCharFunc(target, charParam){
	if(typeof(target) == "string"){
		if(target[target.length-1] == charParam){
			return target.substring(0, target.length-1);
		}
		return target;
	}
	return target;
}